﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Manager_Sanpham1_Controls_UC_Sanpham : System.Web.UI.UserControl
{
    BUS_Product data = new BUS_Product();
    BUS_Manufacturer data2 = new BUS_Manufacturer();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["type"] == null || Request.QueryString["type"] == "nsx")
            {

                GVQLSP.DataSource = data2.Manufacturer_GetByAll();
                GVQLSP.DataBind();
            }
            else if (Request.QueryString["type"] == "nhom")
            {
                Response.Write("cxmvkhkjxhvkjxhkjvhxkjh");
                //GridView1.DataSource = data2.Manufacturer_GetByAll();
                //GridView1.DataBind();
            }
        }
    }
    public string getUrlLoaisanpham(string Id)
    {
        return "~/Manager/Sanpham/Loaisanpham.aspx?id_nsx=" + Id;
    }
    public string getUrlSuaLoaisanpham(string Id)
    {

        return "~/Manager/Sanpham/SuaLoaisanpham.aspx?id_nsx=" + Id;
    }
    public string getsoluong(string Id)
    {
        var DT = data.Product_GetByTop(0, "Manufacturer_Id=" + Id, "[Order]");
        return DT.Rows.Count.ToString();
    }
    //
    //protected void btnXoa_Click(object sender, EventArgs e)
    //{

    //    //Response.Write("assd");
    //}
    //public string abc()
    //{
    //    string id_nsx = Request.QueryString["id_nsx"].ToString();
    //    return "~/Manager/Sanpham/Sualoaisanpham.aspx?id_nsx=" + id_nsx;
    //    Page.Response.Redirect("~/Manager/Sanpham/Sualoaisanpham.aspx?id_nsx=" + id_nsx);
    //}
    //protected void btnXoa_Click(object sender, EventArgs e)
    //{

    //    Page.Response.Redirect("~/Manager/Sanpham1/Sualoaisanpham.aspx?id_nsx=2");
    //}
    protected void GVQLSP_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Sua")
        {
            Page.Response.Redirect("~/Manager/Sanpham/Sualoaisanpham.aspx?id_nsx="+e.CommandArgument);
        }
    }
    protected void GVQLSP_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GVQLSP.PageIndex = e.NewPageIndex;
        GVQLSP.DataSource = data2.Manufacturer_GetByAll();
        GVQLSP.DataBind();
    }
}